Skip to content

Conversation

@antiguru
Copy link
Member

Introduce a distributor that knows how to partition containers across multiple pushers. This moves the partition logic from container builders into a bespoke trait and implementation instead of mixing two different concepts, building containers, and partitioning them.

It allows us to implement a distributor in the future that only partitions by key, for example when the container doesn't have easy access by row.

Removes the old partition function from container builders.

Introduce a distributor that knows how to partition containers across
multiple pushers. This moves the partition logic from container builders
into a bespoke trait and implementation instead of mixing two different
concepts, building containers, and partitioning them.

It allows us to implement a distributor in the future that only partitions
by key, for example when the container doesn't have easy access by row.

Removes the old `partition` function from container builders.

Signed-off-by: Moritz Hoffmann <[email protected]>

This comment was marked as outdated.

Signed-off-by: Moritz Hoffmann <[email protected]>
@antiguru antiguru requested a review from Copilot August 16, 2025 20:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new Distributor trait that separates partitioning logic from container building responsibilities. This refactoring extracts the partition functionality previously embedded in container builders into a dedicated trait and implementation.

  • Introduces Distributor trait for partitioning containers across multiple pushers
  • Implements DrainContainerDistributor as a hash-based distributor
  • Refactors Exchange to use the new distributor architecture instead of container builder partitioning

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
timely/src/dataflow/channels/pushers/exchange.rs Adds Distributor trait and DrainContainerDistributor implementation, refactors Exchange to use distributor
timely/src/dataflow/channels/pact.rs Updates ExchangeCore to use DrainContainerDistributor with new type signature
container/src/lib.rs Removes partition method from ContainerBuilder trait

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@frankmcsherry frankmcsherry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Minor clarity comments. Holding of on any merging to sequence with the other active PR.

Comment on lines 54 to 56
if self.builders.len() != pushers.len() {
self.builders.resize_with(pushers.len(), Default::default);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this .. helpful or should this assert instead? I'm not sure how this gets used, and .. maybe this is a convenient way to initialize things I can't tell.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like, probably not going to happen .. but if this ever truncates then there may be a problem, if container builders get dropped holding on to records. Asserting seems better, or at least asserting if this would ever reduce the length.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the number of peers as part of the constructor. Seems better than to resize at runtime. Also added a debug assert to make sure the lengths match.

Copy link
Member

@frankmcsherry frankmcsherry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look great!

@antiguru antiguru merged commit d5c66b5 into TimelyDataflow:master Aug 28, 2025
7 checks passed
@antiguru antiguru deleted the distributor branch August 28, 2025 19:14
@github-actions github-actions bot mentioned this pull request Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants